//
//  UIButton+GCDImage.m
//  UI16_GCD
//
//  Created by 丶叫你们领导来见我 on 14-10-6.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

//#import "UIButton+GCDImage.h"
//
//@implementation UIButton (GCDImage)
//- (void)setBackgroundImageWithURL:(NSString *)imageURL forState:(UIControlState)state
//{
//    NSInteger name = [imageURL hash];  //缓存
//    NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
//    path = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%u", name]];
//    NSData *imageData = [NSData dataWithContentsOfFile:path];
//    if (imageData) {
//        [self setBackgroundImage:[UIImage imageWithData:imageData] forState:state];
//    }else{
//        
//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//            NSURL *url = [NSURL URLWithString:imageURL];
//            NSData *data = [NSData dataWithContentsOfURL:url];
//            UIImage *image = [UIImage imageWithData:data];
//            [data writeToFile:path atomically:YES];   //存文件
//            dispatch_async(dispatch_get_main_queue(), ^{
//                [self setBackgroundImage:image forState:state];
//            });
//        });
//    }
//    
//}
//@end
